<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>功能包版本信息预览</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <style>
        .layui-form-label{ width: 86px; }
        .layui-form-item .layui-input-inline{ width: 265px; }
        .layui-input-block{ margin-left: 116px;}
    </style>
</head>
<body>

<div class="layui-form" style="padding: 20px 30px 0 0;">

    <div class="layui-form-item">
        <label class="layui-form-label">所属应用</label>
        <div class="layui-input-block">
            <select name="quick_id" lay-search>
                <option value="0"></option>
                {foreach $apps as $k => $v}
                <option value="{$v.id}" {$info['quick_id'] == $v['id'] ? 'selected' : ''}>{$v.name}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">所属投放号</label>
        <div class="layui-input-block">
            <select name="channel_id" lay-search>
                <option value="0"></option>
                {foreach $channels as $v}
                <option value="{$v['id']}" {$info['channel_id'] == $v['id'] ? 'selected' : ''}>{$v['name']}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="hidden" name="id" value="{$info.id}" />
        <button class="layui-btn" lay-submit lay-filter="LAY-data-edit-submit" id="LAY-data-edit-submit">提交</button>
    </div>
</div>
<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['index', 'form','upload'], function(){
        var $ = layui.$
            ,upload = layui.upload
            ,form = layui.form;

        upload.render({
            elem: '#appLogo'
            ,accept:'images'
            ,acceptMime: 'image/jpeg, image/png, image/jpg'
            ,url: '/tool/uploadPic' //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
            ,done: function(res){
                if (res.code !== 0){
                    layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.data.picUrl);
                    layui.$('#uploadDemoView').find('input').val(res.data.filePath);
                    layui.$('#cover_head').addClass('layui-hide');
                    console.log(res)
                }else {
                    layer.msg(res.msg);
                }
            }
        });

        form.on('radio(hot_update)', function(data){
            console.log(data.value);
            if(data.value == '1')
            {
                layer.msg('选择热更新请上传wgt后缀格式');
                return false;
            }else{
                layer.msg('非热更新请上传apk后缀格式');
                return false;
            }

        });

        var uploadHc = upload.render({
            elem: '#upload-apk'
            ,url: "{:url('Tool/UploadFile',array('dirName'=>'apk') )}"
            ,accept: 'file'
            ,method: 'get'
            ,done: function(res){
                if(res.code < 1){
                    layer.msg(res.msg);
                    return false;
                }
                var obj = $(this.item).parent();
                $(this.item).prev("div").children("input").val(res.data.filePath);
            }
            ,error: function(){
                //失败状态，并实现重传
                var obj = $(this.item).parent();
                obj.find('.layui-upload-list .tipText').html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                obj.find('.layui-upload-list .tipText .demo-reload').on('click', function(){
                    uploadHc.upload();
                });
            }
        });


    })

</script>
</body>
</html>